#include<bits/stdc++.h>
using namespace std;

const int MAXN=100;

int nextTable[MAXN];

void GetNextTable(string pattern){
    int m=pattern.size();
    int j=0;
    nextTable[j]=-1;
    int t=nextTable[j];
    while(j<m){
        if(t==-1||pattern[j]==pattern[t]){
            t++,j++;
            nextTable[j]=t;
        }else{
            t=nextTable[t];
        }
    }
}

int KMP(string test,string pattern){
    GetNextTable(pattern);
    int n=test.size();
    int m=pattern.size();
    int i=0,j=0;
    while(i<n&&j<m){
        if(j==-1||test[i]==pattern[j]){
            i++,j++;
        }else{
            j=nextTable[j];
        }
    }
    if(j==m){
        return i-j;
    }else{
        return -1;
    }
}

int main(){
    string test,pattern;
    cin>>test>>pattern;
    int position=KMP(test,pattern);
    cout<<position<<endl;
    return 0;
}
